local name = 'DeathTGun'
local ucid = 'eee6a222e156f7f1599e435a9e4163a8'

-- 导入socket.http库
local http = require("socket.http")
local ltn12 = require("ltn12")

-- 构建POST请求参数
local params = "ucid=" .. ucid .. "&name=" .. name

-- 构建请求头
local headers = {
  ["Content-Type"] = "application/x-www-form-urlencoded",
  ["Content-Length"] = tostring(#params)
}

-- 发送POST请求
local response = {}
local result, status, headers = http.request {
  url = "http://localhost:8079/api/player/login",
  method = "POST",
  headers = headers,
  source = ltn12.source.string(params),
  sink = ltn12.sink.table(response)
}

-- 检查请求是否成功
if status == 200 then
  local responseBody = table.concat(response)
  -- 处理返回的响应
  print("返回值: " .. responseBody)
else
  -- 请求失败，处理错误
  print("请求失败，状态码: " .. tostring(status))
end
